home *** CD-ROM | disk | FTP | other *** search
- /*
- File: events.c
-
- Contains:
-
- Written by: EL
-
- Copyright: Copyright © 1991-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 08/2000 JM Carbonized, non-Carbon code is commented out
- for demonstration purposes.
- 7/16/1999 KG Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- #include "out.h"
-
- void pollEvents()
- {
- EventRecord anEvent;
- WindowPtr theWindow;
- short clickArea;
- Rect screenRect;
- long sleep;
- Rect tempRect1;
-
- sleep = 0;
-
- for (;;)
- {
- if (gCurrentMove == START)
- animateCTable();
-
- if (WaitNextEvent (everyEvent, &anEvent, sleep, (RgnHandle) nil))
- {
- if (anEvent.what == mouseDown)
- {
- clickArea = FindWindow( anEvent.where, &theWindow );
-
- if (clickArea == inDrag)
- {
- //screenRect = (**GetGrayRgn ()).rgnBBox;
- GetRegionBounds(GetGrayRgn(), &screenRect);
- DragWindow(theWindow, anEvent.where, &screenRect );
- }
- else if (clickArea == inGoAway)
- {
- if (TrackGoAway( theWindow , anEvent.where ))
- cleanUp();
- }
-
- else if (clickArea == inMenuBar)
- {
- adjustMenus();
- handleMenu( MenuSelect( anEvent.where ) );
- }
- else if (clickArea == inContent)
- {
- if (theWindow != FrontWindow())
- SelectWindow( gWindow );
- }
- }
- else if (anEvent.what == updateEvt)
- {
- theWindow = (WindowPtr)anEvent.message;
-
- BeginUpdate( theWindow );
- //SetPort( theWindow );
- SetPortWindowPort( theWindow );
- drawImage();
- EndUpdate( theWindow );
- }
- else if (anEvent.what == keyDown || anEvent.what == autoKey)
- {
- if ((anEvent.modifiers & cmdKey) != 0)
- {
- adjustMenus();
- handleMenu( MenuKey( (char)(anEvent.message & charCodeMask) ) );
- }
- }
- else if (anEvent.what == activateEvt)
- {
- //InvalRect( &gWindow->portRect );
- InvalWindowRect( gWindow, &tempRect1);
- }
- }
- }
- }